import 'package:flutter/material.dart';

void main(List<String> args) {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.red),
      ),
      home: const HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  const HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  List<String> _list = [];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('Flutter app')),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          setState(() {
            _list.add('我是一个列表');
          });
        },
        child: const Icon(Icons.add),
      ),
      body: ListView(
        children: _list.map((value) {
          return ListTile(title: Text(value));
        }).toList(),
      ),
    );
  }
}
